package com.ihr360.insurance.model.dto.ledger.mapped;

import com.ihr360.insurance.entity.snapshot.BenefitSnapshot;
import com.ihr360.insurance.entity.snapshot.CompanyBenefitSnapshot;
import com.ihr360.shared.basicstaffinfo.dto.SyncedBasicStaffInfo;
import com.ihr360.shared.entitywithlistener.NumberIdWithTimeAndCompanyId;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

/**
 * 增减员计划表公共数据表
 *
 * @author davidwei
 */
@MappedSuperclass
public class MemberPlan extends NumberIdWithTimeAndCompanyId<Long> {

    public static final class Field {
        public static final String companyId = "companyId";
        public static final String userId = "userId";
        public static final String year = "year";
        public static final String month = "month";

        public static final String staff = "staff";
        public static final String staff_id = "staff.id";
        public static final String staff_staffName = "staff.staffName";
        public static final String staff_departmentName = "staff.departmentName";
        public static final String staff_idCardNo = "staff.idCardNo";

        public static final String siCompanyBenefit_id = "siCompanyBenefit.id";
        public static final String siCompanyBenefit_name = "siCompanyBenefit.name";
        public static final String hfCompanyBenefit_id = "hfCompanyBenefit.id";
        public static final String hfCompanyBenefit_name = "hfCompanyBenefit.name";

        public static final String socialInsurance_startOn = "socialInsurance.startOn";
        public static final String socialInsurance_endOn = "socialInsurance.endOn";

        public static final String houseFund_startOn = "houseFund.startOn";
        public static final String houseFund_endOn = "houseFund.endOn";

        public static final String inLedger = "inLedger";
    }

    private static final long serialVersionUID = 5738107418320327014L;

    /**
     * 用户id
     */
    @Column(length = 40)
    private String userId;

    @ManyToOne
    @JoinColumn(nullable = false)
    private SyncedBasicStaffInfo staff;

    /**
     * 年份
     */
    @Column(nullable = false, length = 10)
    private Integer year;

    /**
     * 月份
     */
    @Column(nullable = false, length = 4)
    private Integer month;

    /**
     * 是否已存在月度台账中
     */
    private Boolean inLedger;

    /**
     * 社保个人快照信息
     */
    @AttributeOverrides({
            @AttributeOverride(name = "base", column = @Column(name = "si_staff_benefit_base")),
            @AttributeOverride(name = "startOn", column = @Column(name = "si_staff_benefit_start_on")),
            @AttributeOverride(name = "endOn", column = @Column(name = "si_staff_benefit_end_on")),
            @AttributeOverride(name = "calculatable", column = @Column(name = "si_staff_benefit_calculatable"))
    })
    @Embedded
    private BenefitSnapshot socialInsurance;

    /**
     * 社保方案快照信息
     */
    @AttributeOverrides({
            @AttributeOverride(name = "id", column = @Column(name = "si_company_benefit_id")),
            @AttributeOverride(name = "name", column = @Column(name = "si_company_benefit_name"))
    })
    @Embedded
    private CompanyBenefitSnapshot siCompanyBenefit;
    /**
     * 公积金个人快照信息
     */
    @AttributeOverrides({
            @AttributeOverride(name = "base", column = @Column(name = "hf_staff_benefit_base")),
            @AttributeOverride(name = "startOn", column = @Column(name = "hf_staff_benefit_start_on")),
            @AttributeOverride(name = "endOn", column = @Column(name = "hf_staff_benefit_end_on")),
            @AttributeOverride(name = "calculatable", column = @Column(name = "hf_staff_benefit_calculatable"))
    })
    @Embedded
    private BenefitSnapshot houseFund;
    /**
     * 社保方案快照信息
     */
    @AttributeOverrides({
            @AttributeOverride(name = "id", column = @Column(name = "hf_company_benefit_id")),
            @AttributeOverride(name = "name", column = @Column(name = "hf_company_benefit_name"))
    })
    @Embedded
    private CompanyBenefitSnapshot hfCompanyBenefit;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public SyncedBasicStaffInfo getStaff() {
        return staff;
    }

    public void setStaff(SyncedBasicStaffInfo staff) {
        this.staff = staff;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Boolean getInLedger() {
        return inLedger;
    }

    public void setInLedger(Boolean inLedger) {
        this.inLedger = inLedger;
    }

    public BenefitSnapshot getSocialInsurance() {
        return socialInsurance;
    }

    public void setSocialInsurance(BenefitSnapshot socialInsurance) {
        this.socialInsurance = socialInsurance;
    }

    public CompanyBenefitSnapshot getSiCompanyBenefit() {
        return siCompanyBenefit;
    }

    public void setSiCompanyBenefit(CompanyBenefitSnapshot siCompanyBenefit) {
        this.siCompanyBenefit = siCompanyBenefit;
    }

    public BenefitSnapshot getHouseFund() {
        return houseFund;
    }

    public void setHouseFund(BenefitSnapshot houseFund) {
        this.houseFund = houseFund;
    }

    public CompanyBenefitSnapshot getHfCompanyBenefit() {
        return hfCompanyBenefit;
    }

    public void setHfCompanyBenefit(CompanyBenefitSnapshot hfCompanyBenefit) {
        this.hfCompanyBenefit = hfCompanyBenefit;
    }
}